const mongoose = require('mongoose')
const baseModel = require('./base-model')
const Schema = mongoose.Schema

// 为集合（表）创建模式（schema)
// 注意：调用Date.now方法，而不是函数
const articleSchema = mongoose.Schema({
    ...baseModel,
    title: {
        type: String,
        required: true
    },
    description: {
        type: String,
        required: true
    },
    body: {
        type: String,
        required: true
    },
    tagList: {
        type: [String],
        default: null
    },
    favoritesCount: {
        type: Number,
        default: 0
    },
    author: {
        type: Schema.Types.ObjectId,
        ref:'User',
        required: true
    }
});

module.exports = articleSchema